﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace DataModels.Models.OfflineData
{/// <summary>
    /// Represents all in the information that will be saved as offline report
    /// </summary>
    public class OfflineReport
    {
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }

        /// <summary>
        /// Facility Code
        /// </summary>
        public string FacilityCode { get; set; }

        /// <summary>
        /// Facility Name
        /// </summary>
        public string FacilityName { get; set; }

        /// <summary>
        /// Report Year
        /// </summary>
        public int ReportYear { get; set; }

        /// <summary>
        /// Report Month
        /// </summary>
        public int ReportMonth { get; set; }

        /// <summary>
        /// The time this report was saved offline.
        /// </summary>
        public DateTime DateSavedOffline { get; set; }

        /// <summary>
        /// Unique identifier of report being saved
        /// </summary>
        public int ReportId { get; set; }

        /// <summary>
        /// Report Name
        /// </summary>
        public string ReportName { get; set; }

        /// <summary>
        /// Report data presentation as SMS
        /// </summary>
        public string ReportMessage { get; set; }

        /// <summary>
        /// Unique identifer of the user who created this offline data
        /// </summary>
        public int CreatedByUserId { get; set; }

        /// <summary>
        /// Name of the user who created this offline data
        /// </summary>
        public string CreatedByUserName { get; set; }

        /// <summary>
        /// Report comments
        /// </summary>
        public string ReportComments { get; set; }

        [NotMapped]
        [XmlIgnore]
        public bool Skipped { get; set; }
        
        [NotMapped]
        [XmlIgnore]
        public object Tag { get; set; }

        /// <summary>
        /// Report indicators
        /// </summary>
        public virtual List<OfflineReportIndicator> Indicators { get; set; }

        [ForeignKey("FacilityCode")]
        public virtual Facility Facility { get; set; }

        [ForeignKey("ReportId")]
        public virtual Report Report { get; set; }

        [ForeignKey("CreatedByUserId")]
        public virtual User CreatedByUser { get; set; }
    }

    /// <summary>
    /// This is convenience class for collection of OfflineReport objects
    /// </summary>
    public class OfflineReportCollection : List<OfflineReport> { }
}
